function showResult() {
    var roleName = $('#roleNameId').val();
    var arr = [];
    $('input[type="checkbox"]:checked').each(function () {
        arr.push($(this).val());
    });
    var settings = {
        url: '/kobe/addRole.do?rName=' + roleName,
        method: 'post',
        headers: {
            'content-type': 'application/json'
        },
        data: JSON.stringify(arr)
    };
    $.ajax(settings).done(requestFinished);
}

function requestFinished(resp) {
    if (resp) {
        $('#save_result_info').attr('class', 'save_success').text('保存成功!');
        showResultDiv(true);
        window.setTimeout("showResultDiv(false);", 3000);
    } else {
        $('#save_result_info').attr('class', 'save_fail').text('保存失败!');
        showResultDiv(true);
        window.setTimeout("showResultDiv(false);", 3000);
    }
}

function showResultDiv(flag) {
    var divResult = document.getElementById("save_result_info");
    if (flag)
        divResult.style.display = "block";
    else
        divResult.style.display = "none";
}

function cancelResult() {
    $('#roleNameId').val('');
    $('input[type="checkbox"]:checked').attr("checked", false);
}
